#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
#include <vector>
class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {
        long long x = 0;
        for (auto e : nums)
        {
            x ^= e;
        }
        long long tmp = x & (-x);
        int x1 = 0;
        int x2 = 0;
        for (auto e : nums)
        {
            if ((e & tmp) == tmp)
            {
                x1 ^= e;
            }
            else
            {
                x2 ^= e;
            }
        }
        return { x1,x2 };
    }
};

class Solution {
public:
    bool isUnique(string astr) {
        unordered_map<char, int> hash;
        for (auto e : astr)
        {
            if (hash.count(e) == 0)
                hash[e]++;
            else
                return false;
        }
        return true;
    }
};

class Solution {
public:
    bool isUnique(string astr) {
        int mapbit = 0;
        for (auto e : astr)
        {
            int i = e - 'a';
            if ((mapbit >> i) & 1)
                return false;
            else
                mapbit |= (1 << i);
        }
        return true;
    }
};

class Solution {
public:
    int missingNumber(vector<int>& nums) {
        int len = nums.size();
        int ret = 0;
        for (int i = 0; i < len; i++)
        {
            ret ^= i;
            ret ^= nums[i];
        }
        ret ^= len;
        if (ret)
            return ret;
        else
            return 0;
    }
};
class Solution {
public:
    int getSum(int a, int b) {
        int m = a ^ b;
        int n = (a & b) << 1;
        while (n)
        {
            m = a ^ b;
            n = (a & b) << 1;
            a = m;
            b = n;
        }
        return m;
    }
};
int main()
{
    Solution s;
    vector<int> nums = { 1,2,1,3,2,5 };
    s.singleNumber(nums);
    return 0;
}
//class Solution {
//public:
//    vector<int> countBits(int n) {
//        vector<int> ret(n + 1);
//
//        for (int i = 0; i <= n; i++)
//        {
//            int tmp = i;
//            int count = 0;
//            while (tmp)
//            {
//                tmp &= tmp - 1;
//                count++;
//            }
//            ret[i] = count;
//        }
//        return ret;
//    }
//};
//
//class Solution {
//public:
//    int hammingDistance(int x, int y) {
//        x ^= y;
//        int ret = 0;
//        while (x)
//        {
//            x &= (x - 1);
//            ret++;
//        }
//        return ret;
//    }
//};

#include <iostream>
using namespace std;
#include <vector>
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<char>> arr(n, vector<char>(m));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> arr[i][j];
        }
    }
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            int num = 0;
            if (arr[i - 1][j - 1] == 'l')
                num = 4;
            else if (arr[i - 1][j - 1] == 'o')
                num = 3;
            else if (arr[i - 1][j - 1] == 'v')
                num = 2;
            else if (arr[i - 1][j - 1] == 'e')
                num = 1;
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + num;
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}